<template>
  <div class="set-bg-color">
    <div
      v-for="(item, index) in bgColorArr"
      :key="index"
      class="bg-box"
      @click="selectBg(item.name)"
    >
      <div
        class="color-box"
        :style="{backgroundColor: item.style.body['background-color']}"
      ></div>
      <div class="color-text">{{ item.name }}</div>
    </div>
  </div>
</template>

<script>
  import EventEmitter from '@/utils';
  export default {
    props: {
      bgColorArr: {
        type: Array,
        default: [],
      },
    },
    methods: {
      selectBg (name) {
        EventEmitter.emit('setBgColor', name);
      }
    },
  }
</script>

<style lang="scss" scoped>
@import '@/assets/style/global.scss';
.set-bg-color {
  @include flexLayout;
  height: 100%;
  padding: 0 px2rem(30);
  .bg-box {
    width: 22%;
    .color-box {
      border: 1px solid #eee;
      height: px2rem(40);
    }
    .color-text {
      margin-top: px2rem(15);
      font-size: px2rem(24);
      color: #bbb;
      text-align: center;
    }
  }
}
</style>